<?
  //ini_set("session.cookie_lifetime",1);
  session_set_cookie_params(11);
  session_save_path("./tmp/"); 
  session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

  
  require_once "db.php";
  $dsn="mysql://root:@localhost/yule_1979";
  $db=DB::connect($dsn);
  $db->query("set names utf8");

//测试
//-------------------------------

$user_int = "1+7-3=5 and then do - 5 + 4 which equals: 4";   
$sanitized_int = filter_var($user_int, FILTER_SANITIZE_NUMBER_INT);  
echo $sanitized_int;

$user=$_POST['user'];
$pass=$_POST['pass'];
$email=$_POST['email'];
$id=$_POST['id'];
if ($_POST['sel']=='1')
{
if ($user&&$pass)
{
    //RegUser($id,$user,$pass,$email);
    echo  $_POST['sel'];
}
}
else if($_POST['sel']=='2')
{
    switch($_POST["xuanze"])
    {
     case "1":
        //session_set_cookie_params(60);
        //session_start();
        $_SESSION["test"]="ok";  
        break;
     case "2":
        //session_save_path("./tmp/"); 
        //echo session_id();
        echo "aa".$_SESSION["test"]."b";
        break;
     case "3":
        session_start();
        unset($_SESSION["test"]);
        session_destroy();
        break;      

    }

}
//注册
function RegUser($id,$user,$pass,$email)
{
  $dsn="mysql://root:@localhost/yule_1979";
  $db=DB::connect($dsn);
  $db->query("set names utf8");
  
    $result=$db->prepare('insert into yh_info(id,xm,mpass,yj)values(?,?,?,?)');
    $data=array($id,$user,$pass,$email);
    $db->execute($result,$data);    
    
}

?>
  <form action="noname2.php" method="post">
    <input type="textbox" name="id"/>
    <input type="textbox" name="user"/>
    <input type="textbox" name="pass" />
    <input type="textbox" name="email"/>
    <input type="submit" />
    <input type=hidden value="1" name="sel"/>
  </form>

  <form action="noname2.php" method="post">
    <select name="xuanze">
        <option value="1">声明session</option>
        <option value="2">读取session</option>
        <option value="3">删除session</option>
    </select>
    <input type="submit"  />
    <input type=hidden value="2" name="sel"/>
  </form> 
<?
//找回密码

//修改密码

//发送验证信

//接受验证信
  
  
$db->disconnect();
?>
